package com.compty.paint.service.impl;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import com.compty.core.framework.util.PropertiesUtil;

public class DBUtil {
	
	public static Connection getConnection(){
		
		PropertiesUtil propertiesUtil = new PropertiesUtil("conf/jdbc.properties");
		String driverClassName = propertiesUtil.getProperties("jdbc.driverClassName");
		String url = propertiesUtil.getProperties("jdbc.url");
		String username = propertiesUtil.getProperties("jdbc.username");
		String password = propertiesUtil.getProperties("jdbc.password");
		
		try {
			
			Class.forName(driverClassName);
			Connection conn = DriverManager.getConnection(url,username,password);
			return conn;
			
		} catch (SQLException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		return null;
	}

}
